<template>
  <div class="about">
    <van-nav-bar title="扫码验证" />

    <div class="managePage">
      <div class="sacnCode">
          <div>
            <van-button round type="info" @click="DDscanCode"><span class="iconfont icon-saoyisaosaoma"></span></van-button>
          </div>
      </div>
    </div>
  </div>
</template>

<script>
import * as dd from 'dingtalk-jsapi';
import awsuiAxios from "../awsuiAxios";
import { Toast } from 'vant';
export default {
data(){
    return {

    }
},
methods:{
     DDscanCode(){
      const that = this;
      dd.ready(function () {
         console.log("ddddd");
        dd.biz.util.scan({
            type: 'all', // type 为 all、qrCode、barCode，默认是all。
            onSuccess: function (val) {
              var textCurrent = val.text
              that.getinfo(textCurrent);
              // that.show = true;
            },
            onFail: function (err) {
              console.log(err);
            }
        })
      });
    },
    getinfo(val){
      console.log(typeof val)
      const that = this;
       awsuiAxios.post({
              url: 'jd',
                data: {
                    cmd: "com.awspaas.user.apps.assetmanagement_selectAssetInfo",
                    sid:sid,
                    anln:val
                }
            }).then(function (ro) {
                if (ro.result == 'ok') {
                    that.message = ro.data.staffList
                    that.$router.push({path:'/show',query:{data:ro.data.staffList}})
                    console.log(ro);
                }else{
                        Toast.fail('扫码失败：' + ro.msg);
                      }
            }).catch(error => {
                console.log(error);
            })
    },
}
}
</script>

<style scoped>
.van-button{
    width: 100px;
    height: 100px;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    margin: auto;
}
.iconfont{
    font-size: 32px;
}
</style>